import React from "react";
import { useGlobalDispatch } from '@jiatuan/hooks';
import { useStripes } from '@jiatuan/yunhan-core'

function Langs(props) {
    const globalDispatch = useGlobalDispatch()
    const stripes = useStripes()

    return (
        <div
            style={{
                color: 'white',
                border: '1px solid #fff',
                padding: '3px 8px',
                cursor: 'pointer'
            }}
            onClick={() => {
                const lang = stripes.locale === 'zh-CN' ? 'en-US' : 'zh-CN'

                globalDispatch({
                    type: 'setLang',
                    payload: {
                        lang
                    }
                });

                stripes.setLocale(lang)
            }}
        >
            {stripes.lang}
        </div>
    )
}

export default Langs;